
/*
 * @Description: 
 * @Author: rendc
 * @Date: 2024-10-14 14:45:22
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-14 16:45:54
 */
/**
 * Test04
 */
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class Test05 {

  public static void main(String[] args) throws IOException {
    // 1. 声明流
    // 文件输出流
    // FileOutputStream(path)
    // 2. 创建流
    OutputStream outputStream = new FileOutputStream("/Users/cc/Desktop/Java/day32/test.txt", true);
    System.out.println("outputStream: " + outputStream);
    // 3. 使用流
    // ⚠️ write方法会覆盖原文件的内容
    outputStream.write(99);
    outputStream.write(98);
    outputStream.write(97);
    String str = "\nhello";
    byte[] bytes = str.getBytes();
    outputStream.write(bytes);
    // outputStream.write(bytes, 0, 3);
    // 4. 关闭流
    outputStream.close();
  }
}